<?php
namespace API\Controller;
use Think\Controller;
/**
* 关注逻辑
*/
/*
	1：文章；2：新闻；3：电影；
	 */
class CommentsController extends Controller
{
	
	/**
	 * 添加关注/取消关注
	 * @return [type] [description]
	 */
	public function addcomments(){
		if(IS_POST){
			$data['u_id'] = I('post.u_id');
			$data['comment_flag'] = I('post.comment_flag');
			$data['comment_id'] = I('post.comment_id');
			$data['com_content'] = I('post.com_content');
		}
		elseif (IS_GET) {
			$data['u_id'] = I('get.u_id');
			$data['comment_flag'] = I('get.comment_flag');
			$data['comment_id'] = I('get.comment_id');
			$data['com_content'] = I('post.com_content');
		}
		// if(!empty($data['u_id'])&&!empty($data['comment_flag'])&&!empty($data['comment_id'])){
				$comments = M('comments');
				$state = $comments -> where($data) -> add();
				// if(empty($state['col_id'])){
					/**
					 * 添加关注
					 */
					 $data['com_content'] = I('get.com_content'); 
					$data['com_time'] = array('exp','now()');
					$res = $comments -> add($data);
					$result = $res ? 1 : 0;
					if($result){
						$sent = array("success"=>1);
						echo json_encode($sent);
					}else{
						$sent = array("success"=>0);
						echo json_encode($sent);
					}

	}


	
}